package com.itheima.tanhua.vo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.itheima.tanhua.domain.Announcement;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author Lff
 * @date 2022/3/31
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AnnouncementVo implements Serializable {
    private String id;
    private String title;
    private String description;
    private String createDate;

    public static AnnouncementVo init(Announcement announcement) {
        AnnouncementVo announcementVo = new AnnouncementVo();
        BeanUtils.copyProperties(announcement, announcementVo, "createDate", "id");
        String format = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(announcement.getCreateDate());
//        announcementVo.setCreate(announcement.getCreateDate());
        announcementVo.setCreateDate(format);
        announcementVo.setId(announcement.getId().toString());
        return announcementVo;
    }
}
